package com.junchenrobot.mes.enums;

import lombok.Getter;

import java.util.Objects;

@Getter
public enum DeviceStatusEnum {

    /**
     * 离线
     */
    OFFLINE(1, "offline"),
    /**
     * 无效
     */
    INVALID(2, "invalid"),
    /**
     *正在充电
     */
    CHARGING(3, "charging"),
    /**
     *正在执行任务
     */
    RUNNING(4, "running"),
    /**
     *空闲
     */
        IDLE(5, "idle"),
    /**
     *车辆任务被放弃
     */
    ABORTED(6, "aborted"),
    /**
     * 禁用小车
     */
    PROHIBITED_TROLLEY(99,"禁用小车");
    
    
    final int index;
    
    final String explain;
    
    DeviceStatusEnum(int index, String explain) {
        this.index = index;
        this.explain = explain;
    }
    
    /**
     * 异常状态
     *
     * @return int
     */
    public static boolean isException(String explain) {
        for (DeviceStatusEnum value : values()) {
            if (Objects.equals(value.explain, explain)) {
                return value.index < 4;
            }
        }
        return false;
    }
    
}
